/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.structural.facade;

import com.behavioral.command.ApagarServer;
import com.behavioral.command.Command;
import com.behavioral.command.EncenderServer;
import com.behavioral.command.Invoker;
import com.behavioral.command.ResetServer;
import com.behavioral.command.Server;
import com.behavioral.command.ServerFTP;
import com.behavioral.command.ServerWeb;
import com.behavioral.command.SeverISMTP;
import com.creational.factorymethod.ConcreteFactory;
import com.creational.factorymethod.Factory;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author jmg
 */
public class ServerFacade {
    
    
    public void ejecutarAccionServer(EnumServer server , EnumAccion accion){
      
        try {
            Factory<Server,EnumServer> factoryServer = new ConcreteFactory("factorymethod.conf");
            
            Server s = factoryServer.createObject(server);
         
            Factory<Command,EnumAccion> factoryCommand = new ConcreteFactory("factorymethod.conf");
            Command command = factoryCommand.createObject(accion);
            
            command.setServer(s);
            
            Invoker invoker = new Invoker(command);
            
            invoker.run();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(ServerFacade.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(ServerFacade.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(ServerFacade.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        
    }
    
    
}
